<template>
  <div class="basic">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <div class="page-left">
          <div class="hotel-name">
            <el-form-item label="酒店名称" prop="hotelname">
                <el-input v-model="ruleForm.hotelname" placeholder="请输入酒店名称" :disabled="true"></el-input>
            </el-form-item>
            <!-- <div class="btn">
              <el-button type="text" @click="hotelName">增加别名</el-button>
            </div> -->
          </div>
          <el-form-item label="房型名称" prop="name">
              <el-input v-model="ruleForm.name" placeholder="请填写房型名称"></el-input>
          </el-form-item>
           <el-form-item label="床型" prop="bedTypeId">
              <el-select v-model="ruleForm.bedTypeId" placeholder="请选择">
              <el-option label="大床" :value="one"></el-option>
              <el-option label="双人" :value="two"></el-option>
              <el-option label="小床" :value="three"></el-option>
              </el-select>
          </el-form-item>
          <el-form-item label="有无窗户" prop="hasWindows">
              <el-select v-model="ruleForm.hasWindows" placeholder="请选择">
              <el-option label="有窗" value="1"></el-option>
              <el-option label="无窗" value="0"></el-option>
              </el-select>
          </el-form-item>
          <el-form-item label="房间类型" prop="roomType">
              <el-select v-model="ruleForm.roomType" placeholder="请选择">
              <el-option label="豪华双人间" value="豪华双人间"></el-option>
              <el-option label="豪华单人间" value="豪华单人间"></el-option>
              <el-option label="标准单人间" value="标准单人间"></el-option>
              </el-select>
          </el-form-item>
          <el-form-item label="房间数" prop="roomnumber">
              <el-input v-model="ruleForm.roomnumber" placeholder="请输入房间数量"></el-input>
          </el-form-item>
          <el-form-item label="楼层" prop="floor">
              <el-input v-model="ruleForm.floor" placeholder="请输入楼层"></el-input>
          </el-form-item>
        </div>
        <div class="page-right">
          <el-form-item label="英文名称"  prop="hotelenname">
              <el-input v-model="ruleForm.hotelenname" placeholder="请填写酒店英文名" :disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="英文名称" prop="enName">
              <el-input v-model="ruleForm.enName" placeholder="请填写房型英文名"></el-input>
          </el-form-item>
          <div class="call">
            <div class="input-left">
              <el-form-item label="房型面积" prop="roomAcreage">
                <el-input v-model="ruleForm.roomAcreage" placeholder="请输入房型面积"></el-input>
              </el-form-item>
            </div>
            <div class="input-right">
              <el-form-item label="最多入住" prop="maxCheck">
                <el-input v-model="ruleForm.maxCheck" placeholder="请输入最多入住"></el-input>
              </el-form-item>
            </div>
          </div>
          <el-form-item label="房型说明" prop="description">
              <el-input type="textarea" v-model="ruleForm.description" placeholder="请输入房型说明"></el-input>
          </el-form-item>
        </div>
    </el-form>
     <div class="information-btn">
            <el-form-item>
                <el-button type="primary" @click="saveForm">保存</el-button>
                <el-button @click="back">取消</el-button>
            </el-form-item>
          </div>
  </div>
</template>
<script>
const ButtonFooter = () => import('@/components/common/ButtonFooter')
export default {
  name: 'BasicInformation',
  data () {
    return {
      one: 1,
      two: 0,
      three: 3,
      value8: '',
      hotelAliases: [],
      options: [{
        value: 'zhinan',
        label: '指南',
        children: [{
          value: 'zhinan',
          label: '指南'
        }]
      }],
      ruleForm: {
        timestamp: 0,
        version: 'string',
        operation: 'string',
        hotelname: '长沙万达文化酒店',
        name: '',
        bedTypeId: '',
        hasWindows: '',
        roomType: '',
        roomnumber: '',
        floor: '',
        hotelenname: 'ChangShaWanDaWenHua',
        enName: '',
        roomAcreage: '',
        maxCheck: '',
        description: ''
      },
      // 测试数据
      test: {
        timestamp: 0,
        version: 'string',
        operation: 'string',
        hotelId: 452,
        name: '房型2',
        bedTypeId: 2,
        hasWindows: 'no',
        roomType: '豪华单人间',
        // roomnumber: '23',
        floor: '36',
        // hotelenname: '',
        enName: 'room2',
        roomAcreage: '35',
        maxCheck: '3',
        description: '房间很赞！！'
      },
      rules: {
        name: [
          { required: true },
          { min: 3, max: 5 }
        ],
        enName: [
          { required: true }
        ]
        // name: [
        //   { required: true, message: '请输入房型名称', trigger: 'blur' },
        //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        // ],
        // enName: [
        //   { required: true, message: '房型英文名称不能为空', trigger: 'blur' }
        // ]
      }
    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    // 发送提交请求
    saveForm () {
      this.$http.post('http://222.244.146.208/room/add?token=' + window.commo.token, this.test).then(res => {
        if (res.data.errCode) {
          this.$alert(res.data.errMsg, '提示', {
            confirmButtonText: '确定',
            type: 'warning',
            callback: action => {
            }
          })
        }
      })
    },
    back () {
      this.$router.go(-1)
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    },
    hotelName () {
      this.hotelAliases.push({name: ''})
    },
    deleteItem (index) {
      this.hotelAliases.splice(index, 1)
    }
  },
  components: {
    ButtonFooter
  }
}
</script>
<style lang="scss">
   .basic {
    margin-bottom: 30px;
    color: #415161;
    .page-left, .page-right {
      width: 45%;
      .el-form-item  {
        margin-bottom: 20px;
      }
    }
    .page-left {
      float: left;
      .hotel-aliases, .hotel-name {
        position: relative;
        .btn, .delete {
          position: absolute;
          bottom: 0;
        }
        .delete {
          right: -4%;
        }
        .btn {
          right: -10%;
        }
      }
    }
    .page-right {
      float: right;
      margin-right: 60px
    }
  }
  .el-cascader, .el-select, .el-date-editor.el-input, .el-date-editor.el-input__inner {
    width: 100%;
  }
  .latitude-longitude {
    display: block;
    .input-left, .input-right {
      width: 50%;
      .el-input {
        width: 80%;
        float: left;
      }
      label {
        margin-left: -3%;
        font-size: 12px;
      }
    }
    .input-left {
      float: left;
    }
    .input-right {
      float: right;
      margin-right: -3%;
    }
  }
  .call {
    overflow: hidden;
    .input-left, .input-right {
      width: 50%;
    }
    .input-left {
      float: left;
    }
    .input-right {
      float: right;
    }
  }
</style>
